package coo1;

import java.util.Scanner;

public class Compute2 {
    protected int a;
    String s1, str = "";
    int level;

    public Compute2(){
        String s1 = "", str = "";
        int level = 1;
    }

    public String Computing(int x){
        level = x;
        int a1 = (int) (Math.random()*100);//形成一级式
        int a2 = (int) (Math.random()*100);
        int t1 = (int) (Math.random()*4);
        switch (t1){
            case 0:{
                s1 = " + ";
                break;
            }
            case 1:{
                s1 = " - ";
                break;
            }
            case 2:{
                s1 = " * ";
                break;
            }
            case 3:{
                s1 = " / ";
            }
        }
        for (int i = 0; i < level - 1; i++){//循环，将一级式添加为多级
            int a = (int) (Math.random()*100);
            int t = (int) (Math.random()*4);
            String s = "";
            switch (t){
                case 0:{
                    s = " + ";
                    break;
                }
                case 1:{
                    s = " - ";
                    break;
                }
                case 2:{
                    s = " * ";
                    break;
                }
                case 3:{
                    s = " / ";
                }
            }
            str += a + s;
        }
        str+= a1 + s1 + a2 + " = ";
        return str;
    }



    public void formulaXX(int x){
        String string = " ";
        int y;
        for (int i = 0; i < x; i++){
            Scanner scan = new Scanner(System.in);
            y = scan.nextInt();
            Compute2 com = new Compute2();
            string = "题" + (i + 1) + ": " + com.Computing(y) + "\t\n";
            System.out.println(string);
        }
    }

    public void setLevel(int n){
        level = n;
    }



}
